<?php
declare (strict_types = 1);

namespace app\command;

use app\models\GdzyzActivities;
use app\models\WxMessageRecords;
use app\services\GdzyzService;
use app\services\WeikeyunService;
use app\services\WxService;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class GdzyzCode extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('synchro:gdzyzCode')
            ->setDescription('同步志愿广东二维码');
    }

    protected function execute(Input $input, Output $output)
    {
        try {
            $activities = GdzyzActivities::where([
                ['signStartTime', '<', date('Y-m-d')]
            ])->limit(10)->select();

            foreach ($activities as $activity) {
                (new GdzyzService())->refreshCode($activity);
            }
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage(), 500);
        }
    }
}
